package org.usmile.algorithms.huawei.acm;

import java.util.Scanner;

// https://blog.csdn.net/amos_cloud/article/details/129078084
public class _组装新的数组 {
    private static int[] nums;
    private static int min;
    private static int M;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] costsStr = sc.nextLine().split(" ");
        M = sc.nextInt();
        nums = new int[costsStr.length];
        for (int i = 0; i < costsStr.length; i++) {
            nums[i] = Integer.parseInt(costsStr[i]);
        }
        min = nums[0];

        System.out.println(dfs(0, 0));
    }

    private static int dfs(int index, int currentValue) {
        if (currentValue > M) {
            return 0;
        }
        if (currentValue == M || M - currentValue < min) {
            return 1;
        }

        int count = 0;
        for (int i = index; i < nums.length; i++) {
            count += dfs(i, currentValue + nums[i]);
        }

        return count;
    }
}
